// 创建全局的vuex
import Vue from 'vue';
import Vuex from 'vuex';
//运用”vuex-persistedstate”来对数据进行缓存
import createPersistedState from 'vuex-persistedstate'


Vue.use(Vuex);

const module = {
  state:{
    curs:0,
    iphone:'请登录',
    phone:'',
    bol3:false,
    usernam2:'',
    cityinfo2:'',
    addss2:'',
    pone2:'',
    pay:''
  },
  // 把getters看成是计算属性
  getters:{

  },
  //mutations存放修改state中值的事件
  mutations:{
    changs(state,index){
      state.curs = index;
    },
    showIphone(state,num){
      state.iphone= '你好! '+num;
    },
    showIphone2(state){
      state.iphone='请登录';
    },
    showPhone(state,num1){
      state.phone=num1;
    },
    showPhone2(state){
      state.phone="";
    },
    change4(state){
      state.bol3 = true;
    },
    change5(state){
      state.bol3 = false;
    },
    cunjin1(state,str){
      state.usernam2 = str;
    },
    cunjin2(state,str){
      state.cityinfo2 = str;
    },
    cunjin3(state,str){
      state.addss2 = str;
    },
    cunjin4(state,str){
      state.pone2 = str;
    },
    changepay(state,num){
      state.pay = num;
    }
  },
  plugins:[createPersistedState()]
};

const store = new Vuex.Store(module);

export default store;
